<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 30px;
            border: 1px solid #000;
        }
        .inner{
            width: 0px;
            height: 30px;
            background: red;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="inner"></div>
        <span id="msg">0%</span>
    </div>
    <script>
        var oInner=document.querySelector(".inner");
        var oMsg=document.querySelector("#msg");
        var num=0;
        var timer=setInterval(function(){
            num++;
            oInner.style.width=num+"px";
            oMsg.innerHTML=parseInt(num/200*100)+"%";
            if(num>200){
                clearInterval(timer);
            }
        },50)
    </script>
</body>
</html>